"""
@Author  : 康帅
@Time    : 2021/1/6 14:42
@Function: u:unicode b:字节码
"""

# 字符转Unicode编码
print(hex(ord('中')))
print(hex(ord('A')))

# 字符串转UTF-8(encode)
print('中'.encode('utf-8'))
print('A'.encode('utf-8'))

# Unicode编码还原成字符
print(chr(0x4e2d))
print(chr(0x41))

# UTF-8还原成字符
print(b'\xe4\xb8\xad'.decode('utf-8'))
print(b'A'.decode('utf-8'))
